home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / freeWAIS-sf-1.1 / ir / field_y.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-10  |  51.4 KB  |  1,732 lines

  1.  
  2. /*  A Bison parser, made from /usr/local/ls6/src+data/src/freeWAIS-sf/ir/field_y.y with Bison version GNU Bison version 1.22
  3.   */
  4.  
  5. #define YYBISON 1  /* Identify Bison output.  */
  6.  
  7. #define    WORD    258
  8. #define    REGEXP    259
  9. #define    FIELD    260
  10. #define    END    261
  11. #define    LAYOUT    262
  12. #define    STEMMING    263
  13. #define    ISOUNDEX    264
  14. #define    IPHONIX    265
  15. #define    NUMERIC    266
  16. #define    ITEXT    267
  17. #define    LOCAL    268
  18. #define    GLOBAL    269
  19. #define    BOTH    270
  20. #define    INT    271
  21. #define    IGNORE    272
  22. #define    RECORD_END    273
  23. #define    HEADLINE    274
  24. #define    DATE    275
  25. #define    DAY    276
  26. #define    MONTH    277
  27. #define    YEAR    278
  28. #define    STRING    279
  29. #define    DESCRIPTION    280
  30.  
  31. #line 17 "/usr/local/ls6/src+data/src/freeWAIS-sf/ir/field_y.y"
  32.  
  33. #include "cutil.h"
  34. #include <stdio.h>
  35. /* #include <string.h>*/
  36. #include <ctype.h>
  37. #include "futil.h"
  38. #include "field_index.h"
  39. #include "field_y.h"
  40.  
  41. #define MAX_REGEXP 100
  42. #define YYSTYPE yystype
  43. extern FILE* yyin;
  44. extern int yylineno;
  45. extern char yytext[];
  46. #ifdef YYBISON
  47. int yydebug;
  48. #else
  49. extern int yydebug;
  50. #endif
  51. extern fields_struct** index_fields;
  52. extern nidx_table* Ntable;   /* defined in field_index.c */
  53. extern ltable* Ltable;       /* defined in field_index.c */
  54.  
  55. static long* field_id_set = NULL;
  56. static long gfield_id = 0;
  57. static long gregexp_pos = 0;
  58. static long index_pos = 0;
  59. static long number_of_fields_inserted = 0;
  60. static long number_of_index_fields = 0;
  61. static long number_of_indextypes = 0;
  62. static long number_of_headlines = 0;
  63. static long number_of_regexp = 0;
  64. static long offset = 0;
  65. static int is_headline = 0;
  66. static int regexp_not_empty = 0;
  67. static int fieldlist_not_empty = 0;
  68. static int options_not_empty = 0;
  69. static int indexspecs_not_empty = 0;
  70. static int index_kind = 0;
  71. static int layout_specified = 0;
  72. static boolean global_dct_exists = false;
  73. static boolean index_kind_both = false;
  74. /* ------------------------------------------------------------- */
  75.  
  76. static char** regexp_set = NULL;    /* contains regexp */
  77.  
  78. static void clear_regexp _AP((long number_of_elements));
  79. static void make_ntable _AP((long *pos));
  80. static void make_index_fields _AP((long number_of_elements));
  81. static void put_end_tag_ftable _AP((long field_id, long regexp_pos));
  82. static void put_index_fields _AP((char* field_name, char* field_description, long field_id, long regexp_pos, long index_pos, boolean field_exists));
  83. static void put_numeric_ftable _AP((long n_index_pos,int n_len,long field_id));
  84. static void put_headline _AP((long begin_tag_pos, long end_tag_pos, long hline_begin_tag_pos, long n_len, long n_offset, long number_of_elements));
  85. static long Maxhealine = 0;
  86. static long Nheadline = 0;
  87. static void put_record_end_Ltable _AP((long regexp_pos));
  88. static void put_hdate_ltable _AP((long begin_tag_pos, char* sscanf_arg, char* date1, char* date2, char* date3, long date_begin_tag_pos));
  89. static long Maxregexp = 0;
  90.  
  91. static long insert_regexp _AP((char* regexp, long number_of_elements, long* regexp_pos));
  92. static long create_index_fields _AP((FILE* stream));
  93. static void put_indextypes _AP((char* itype, int i_kind, long field_id, long ipos));
  94. static void put_tags_in_gdb _AP((long field_id,
  95.                      long begin_tag_pos, long begin_tag_pos,
  96.                      long end_tag_pos, long index_pos,
  97.                      long *number_of_index_fields, boolean *both));
  98.  
  99. #line 89 "/usr/local/ls6/src+data/src/freeWAIS-sf/ir/field_y.y"
  100. typedef union {
  101.    int  ival;
  102.    char *sval;
  103.    } YYSTYPE;
  104.  
  105. #ifndef YYLTYPE
  106. typedef
  107.   struct yyltype
  108.     {
  109.       int timestamp;
  110.       int first_line;
  111.       int first_column;
  112.       int last_line;
  113.       int last_column;
  114.       char *text;
  115.    }
  116.   yyltype;
  117.  
  118. #define YYLTYPE yyltype
  119. #endif
  120.  
  121. #include <stdio.h>
  122.  
  123. #ifndef __cplusplus
  124. #ifndef __STDC__
  125. #define const
  126. #endif
  127. #endif
  128.  
  129.  
  130.  
  131. #define    YYFINAL        73
  132. #define    YYFLAG        -32768
  133. #define    YYNTBASE    26
  134.  
  135. #define YYTRANSLATE(x) ((unsigned)(x) <= 280 ? yytranslate[x] : 46)
  136.  
  137. static const char yytranslate[] = {     0,
  138.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  139.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  140.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  141.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  142.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  143.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  144.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  145.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  146.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  147.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  148.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  149.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  150.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  151.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  152.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  153.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  154.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  155.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  156.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  157.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  158.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  159.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  160.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  161.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  162.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  163.      2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
  164.      6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
  165.     16,    17,    18,    19,    20,    21,    22,    23,    24,    25
  166. };
  167.  
  168. #if YYDEBUG != 0
  169. static const short yyprhs[] = {     0,
  170.      0,     4,     7,     8,    12,    14,    17,    25,    31,    33,
  171.     36,    37,    38,    49,    50,    53,    57,    59,    63,    71,
  172.     72,    74,    75,    78,    81,    83,    85,    87,    89,    91,
  173.     93,    95,    98,   100,   101,   103,   104,   106,   107
  174. };
  175.  
  176. static const short yyrhs[] = {    27,
  177.     28,    31,     0,    18,     4,     0,     0,     7,    29,     6,
  178.      0,    30,     0,    30,    29,     0,    20,     4,     4,    42,
  179.     42,    42,    37,     0,    19,     4,     4,    16,    37,     0,
  180.     32,     0,    32,    31,     0,     0,     0,     5,     4,    37,
  181.     33,    45,    34,    35,    38,     6,     4,     0,     0,    36,
  182.     35,     0,    11,    37,    16,     0,     8,     0,    19,    37,
  183.     16,     0,    20,     4,     4,    42,    42,    42,    37,     0,
  184.      0,     4,     0,     0,    39,    38,     0,    40,    41,     0,
  185.     12,     0,     9,     0,    10,     0,    14,     0,    13,     0,
  186.     15,     0,    21,     0,    22,    43,     0,    23,     0,     0,
  187.     24,     0,     0,    25,     0,     0,     3,    44,    45,     0
  188. };
  189.  
  190. #endif
  191.  
  192. #if YYDEBUG != 0
  193. static const short yyrline[] = { 0,
  194.     94,    96,   105,   106,   111,   112,   115,   134,   156,   157,
  195.    159,   171,   181,   248,   249,   255,   275,   287,   305,   327,
  196.    328,   330,   331,   337,   356,   357,   358,   360,   370,   380,
  197.    392,   393,   401,   403,   404,   412,   413,   416,   417
  198. };
  199.  
  200. static const char * const yytname[] = {   "$","error","$illegal.","WORD","REGEXP",
  201. "FIELD","END","LAYOUT","STEMMING","ISOUNDEX","IPHONIX","NUMERIC","ITEXT","LOCAL",
  202. "GLOBAL","BOTH","INT","IGNORE","RECORD_END","HEADLINE","DATE","DAY","MONTH",
  203. "YEAR","STRING","DESCRIPTION","format","record","layout","layoutspecs","layoutspec",
  204. "speclist","spec","@1","@2","options","option","regexp","indexspecs","indexspec",
  205. "indextype","dicts","date","monthspec","descr","fieldlist",""
  206. };
  207. #endif
  208.  
  209. static const short yyr1[] = {     0,
  210.     26,    27,    28,    28,    29,    29,    30,    30,    31,    31,
  211.     33,    34,    32,    35,    35,    36,    36,    36,    36,    37,
  212.     37,    38,    38,    39,    40,    40,    40,    41,    41,    41,
  213.     42,    42,    42,    43,    43,    44,    44,    45,    45
  214. };
  215.  
  216. static const short yyr2[] = {     0,
  217.      3,     2,     0,     3,     1,     2,     7,     5,     1,     2,
  218.      0,     0,    10,     0,     2,     3,     1,     3,     7,     0,
  219.      1,     0,     2,     2,     1,     1,     1,     1,     1,     1,
  220.      1,     2,     1,     0,     1,     0,     1,     0,     3
  221. };
  222.  
  223. static const short yydefact[] = {     0,
  224.      0,     3,     2,     0,     0,     0,     0,     0,     5,     0,
  225.      1,     9,     0,     0,     4,     6,    20,    10,     0,     0,
  226.     21,    11,    20,    31,    34,    33,     0,    38,     8,    35,
  227.     32,     0,    36,    12,    20,    37,    38,    14,     7,    39,
  228.     17,    20,    20,     0,    22,    14,     0,     0,     0,    26,
  229.     27,    25,     0,    22,     0,    15,    16,    18,     0,     0,
  230.     23,    29,    28,    30,    24,     0,    13,     0,    20,    19,
  231.      0,     0,     0
  232. };
  233.  
  234. static const short yydefgoto[] = {    71,
  235.      2,     5,     8,     9,    11,    12,    28,    38,    45,    46,
  236.     22,    53,    54,    55,    65,    27,    31,    37,    34
  237. };
  238.  
  239. static const short yypact[] = {    -9,
  240.      7,    17,-32768,   -16,    10,    21,    22,    23,   -16,    24,
  241. -32768,    10,    26,    27,-32768,-32768,    28,-32768,    11,    -5,
  242. -32768,-32768,    28,-32768,    12,-32768,    -5,    31,-32768,-32768,
  243. -32768,    -5,    13,-32768,    28,-32768,    31,    -6,-32768,-32768,
  244. -32768,    28,    28,    33,    -2,    -6,    19,    25,    35,-32768,
  245. -32768,-32768,    37,    -2,     8,-32768,-32768,-32768,    -5,    40,
  246. -32768,-32768,-32768,-32768,-32768,    -5,-32768,    -5,    28,-32768,
  247.     45,    47,-32768
  248. };
  249.  
  250. static const short yypgoto[] = {-32768,
  251. -32768,-32768,    39,-32768,    38,-32768,-32768,-32768,     3,-32768,
  252.    -23,    -3,-32768,-32768,-32768,   -26,-32768,-32768,    15
  253. };
  254.  
  255.  
  256. #define    YYLAST        52
  257.  
  258.  
  259. static const short yytable[] = {    29,
  260.     32,    41,     6,     7,    42,    35,    50,    51,     1,    52,
  261.      3,    39,    43,    44,    10,    24,    25,    26,    47,    48,
  262.     62,    63,    64,     4,    13,    14,    23,    17,    15,    19,
  263.     20,    21,    66,    33,    57,    30,    49,    36,    59,    68,
  264.     58,    69,    60,    67,    72,    70,    73,    16,    56,    18,
  265.     61,    40
  266. };
  267.  
  268. static const short yycheck[] = {    23,
  269.     27,     8,    19,    20,    11,    32,     9,    10,    18,    12,
  270.      4,    35,    19,    20,     5,    21,    22,    23,    42,    43,
  271.     13,    14,    15,     7,     4,     4,    16,     4,     6,     4,
  272.      4,     4,    59,     3,    16,    24,     4,    25,     4,    66,
  273.     16,    68,     6,     4,     0,    69,     0,     9,    46,    12,
  274.     54,    37
  275. };
  276. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  277. #line 3 "/usr/local/gnulang-94a/lib/bison.simple"
  278.  
  279. /* Skeleton output parser for bison,
  280.    Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
  281.  
  282.    This program is free software; you can redistribute it and/or modify
  283.    it under the terms of the GNU General Public License as published by
  284.    the Free Software Foundation; either version 1, or (at your option)
  285.    any later version.
  286.  
  287.    This program is distributed in the hope that it will be useful,
  288.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  289.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  290.    GNU General Public License for more details.
  291.  
  292.    You should have received a copy of the GNU General Public License
  293.    along with this program; if not, write to the Free Software
  294.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  295.  
  296.  
  297. #ifndef alloca
  298. #ifdef __GNUC__
  299. #define alloca __builtin_alloca
  300. #else /* not GNU C.  */
  301. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
  302. #include <alloca.h>
  303. #else /* not sparc */
  304. #if defined (MSDOS) && !defined (__TURBOC__)
  305. #include <malloc.h>
  306. #else /* not MSDOS, or __TURBOC__ */
  307. #if defined(_AIX)
  308. #include <malloc.h>
  309.  #pragma alloca
  310. #else /* not MSDOS, __TURBOC__, or _AIX */
  311. #ifdef __hpux
  312. #ifdef __cplusplus
  313. extern "C" {
  314. void *alloca (unsigned int);
  315. };
  316. #else /* not __cplusplus */
  317. void *alloca ();
  318. #endif /* not __cplusplus */
  319. #endif /* __hpux */
  320. #endif /* not _AIX */
  321. #endif /* not MSDOS, or __TURBOC__ */
  322. #endif /* not sparc.  */
  323. #endif /* not GNU C.  */
  324. #endif /* alloca not defined.  */
  325.  
  326. /* This is the parser code that is written into each bison parser
  327.   when the %semantic_parser declaration is not specified in the grammar.
  328.   It was written by Richard Stallman by simplifying the hairy parser
  329.   used when %semantic_parser is specified.  */
  330.  
  331. /* Note: there must be only one dollar sign in this file.
  332.    It is replaced by the list of actions, each action
  333.    as one case of the switch.  */
  334.  
  335. #define yyerrok        (yyerrstatus = 0)
  336. #define yyclearin    (yychar = YYEMPTY)
  337. #define YYEMPTY        -2
  338. #define YYEOF        0
  339. #define YYACCEPT    return(0)
  340. #define YYABORT     return(1)
  341. #define YYERROR        goto yyerrlab1
  342. /* Like YYERROR except do call yyerror.
  343.    This remains here temporarily to ease the
  344.    transition to the new meaning of YYERROR, for GCC.
  345.    Once GCC version 2 has supplanted version 1, this can go.  */
  346. #define YYFAIL        goto yyerrlab
  347. #define YYRECOVERING()  (!!yyerrstatus)
  348. #define YYBACKUP(token, value) \
  349. do                                \
  350.   if (yychar == YYEMPTY && yylen == 1)                \
  351.     { yychar = (token), yylval = (value);            \
  352.       yychar1 = YYTRANSLATE (yychar);                \
  353.       YYPOPSTACK;                        \
  354.       goto yybackup;                        \
  355.     }                                \
  356.   else                                \
  357.     { yyerror ("syntax error: cannot back up"); YYERROR; }    \
  358. while (0)
  359.  
  360. #define YYTERROR    1
  361. #define YYERRCODE    256
  362.  
  363. #ifndef YYPURE
  364. #define YYLEX        yylex()
  365. #endif
  366.  
  367. #ifdef YYPURE
  368. #ifdef YYLSP_NEEDED
  369. #define YYLEX        yylex(&yylval, &yylloc)
  370. #else
  371. #define YYLEX        yylex(&yylval)
  372. #endif
  373. #endif
  374.  
  375. /* If nonreentrant, generate the variables here */
  376.  
  377. #ifndef YYPURE
  378.  
  379. int    yychar;            /*  the lookahead symbol        */
  380. YYSTYPE    yylval;            /*  the semantic value of the        */
  381.                 /*  lookahead symbol            */
  382.  
  383. #ifdef YYLSP_NEEDED
  384. YYLTYPE yylloc;            /*  location data for the lookahead    */
  385.                 /*  symbol                */
  386. #endif
  387.  
  388. int yynerrs;            /*  number of parse errors so far       */
  389. #endif  /* not YYPURE */
  390.  
  391. #if YYDEBUG != 0
  392. int yydebug;            /*  nonzero means print parse trace    */
  393. /* Since this is uninitialized, it does not stop multiple parsers
  394.    from coexisting.  */
  395. #endif
  396.  
  397. /*  YYINITDEPTH indicates the initial size of the parser's stacks    */
  398.  
  399. #ifndef    YYINITDEPTH
  400. #define YYINITDEPTH 200
  401. #endif
  402.  
  403. /*  YYMAXDEPTH is the maximum size the stacks can grow to
  404.     (effective only if the built-in stack extension method is used).  */
  405.  
  406. #if YYMAXDEPTH == 0
  407. #undef YYMAXDEPTH
  408. #endif
  409.  
  410. #ifndef YYMAXDEPTH
  411. #define YYMAXDEPTH 10000
  412. #endif
  413.  
  414. /* Prevent warning if -Wstrict-prototypes.  */
  415. #ifdef __GNUC__
  416. int yyparse (void);
  417. #endif
  418.  
  419. #if __GNUC__ > 1        /* GNU C and GNU C++ define this.  */
  420. #define __yy_bcopy(FROM,TO,COUNT)    __builtin_memcpy(TO,FROM,COUNT)
  421. #else                /* not GNU C or C++ */
  422. #ifndef __cplusplus
  423.  
  424. /* This is the most reliable way to avoid incompatibilities
  425.    in available built-in functions on various systems.  */
  426. static void
  427. __yy_bcopy (from, to, count)
  428.      char *from;
  429.      char *to;
  430.      int count;
  431. {
  432.   register char *f = from;
  433.   register char *t = to;
  434.   register int i = count;
  435.  
  436.   while (i-- > 0)
  437.     *t++ = *f++;
  438. }
  439.  
  440. #else /* __cplusplus */
  441.  
  442. /* This is the most reliable way to avoid incompatibilities
  443.    in available built-in functions on various systems.  */
  444. static void
  445. __yy_bcopy (char *from, char *to, int count)
  446. {
  447.   register char *f = from;
  448.   register char *t = to;
  449.   register int i = count;
  450.  
  451.   while (i-- > 0)
  452.     *t++ = *f++;
  453. }
  454.  
  455. #endif
  456. #endif
  457.  
  458. #line 184 "/usr/local/gnulang-94a/lib/bison.simple"
  459. int
  460. yyparse()
  461. {
  462.   register int yystate;
  463.   register int yyn;
  464.   register short *yyssp;
  465.   register YYSTYPE *yyvsp;
  466.   int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
  467.   int yychar1 = 0;        /*  lookahead token as an internal (translated) token number */
  468.  
  469.   short    yyssa[YYINITDEPTH];    /*  the state stack            */
  470.   YYSTYPE yyvsa[YYINITDEPTH];    /*  the semantic value stack        */
  471.  
  472.   short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
  473.   YYSTYPE *yyvs = yyvsa;    /*  to allow yyoverflow to reallocate them elsewhere */
  474.  
  475. #ifdef YYLSP_NEEDED
  476.   YYLTYPE yylsa[YYINITDEPTH];    /*  the location stack            */
  477.   YYLTYPE *yyls = yylsa;
  478.   YYLTYPE *yylsp;
  479.  
  480. #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
  481. #else
  482. #define YYPOPSTACK   (yyvsp--, yyssp--)
  483. #endif
  484.  
  485.   int yystacksize = YYINITDEPTH;
  486.  
  487. #ifdef YYPURE
  488.   int yychar;
  489.   YYSTYPE yylval;
  490.   int yynerrs;
  491. #ifdef YYLSP_NEEDED
  492.   YYLTYPE yylloc;
  493. #endif
  494. #endif
  495.  
  496.   YYSTYPE yyval;        /*  the variable used to return        */
  497.                 /*  semantic values from the action    */
  498.                 /*  routines                */
  499.  
  500.   int yylen;
  501.  
  502. #if YYDEBUG != 0
  503.   if (yydebug)
  504.     fprintf(stderr, "Starting parse\n");
  505. #endif
  506.  
  507.   yystate = 0;
  508.   yyerrstatus = 0;
  509.   yynerrs = 0;
  510.   yychar = YYEMPTY;        /* Cause a token to be read.  */
  511.  
  512.   /* Initialize stack pointers.
  513.      Waste one element of value and location stack
  514.      so that they stay on the same level as the state stack.
  515.      The wasted elements are never initialized.  */
  516.  
  517.   yyssp = yyss - 1;
  518.   yyvsp = yyvs;
  519. #ifdef YYLSP_NEEDED
  520.   yylsp = yyls;
  521. #endif
  522.  
  523. /* Push a new state, which is found in  yystate  .  */
  524. /* In all cases, when you get here, the value and location stacks
  525.    have just been pushed. so pushing a state here evens the stacks.  */
  526. yynewstate:
  527.  
  528.   *++yyssp = yystate;
  529.  
  530.   if (yyssp >= yyss + yystacksize - 1)
  531.     {
  532.       /* Give user a chance to reallocate the stack */
  533.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  534.       YYSTYPE *yyvs1 = yyvs;
  535.       short *yyss1 = yyss;
  536. #ifdef YYLSP_NEEDED
  537.       YYLTYPE *yyls1 = yyls;
  538. #endif
  539.  
  540.       /* Get the current used size of the three stacks, in elements.  */
  541.       int size = yyssp - yyss + 1;
  542.  
  543. #ifdef yyoverflow
  544.       /* Each stack pointer address is followed by the size of
  545.      the data in use in that stack, in bytes.  */
  546. #ifdef YYLSP_NEEDED
  547.       /* This used to be a conditional around just the two extra args,
  548.      but that might be undefined if yyoverflow is a macro.  */
  549.       yyoverflow("parser stack overflow",
  550.          &yyss1, size * sizeof (*yyssp),
  551.          &yyvs1, size * sizeof (*yyvsp),
  552.          &yyls1, size * sizeof (*yylsp),
  553.          &yystacksize);
  554. #else
  555.       yyoverflow("parser stack overflow",
  556.          &yyss1, size * sizeof (*yyssp),
  557.          &yyvs1, size * sizeof (*yyvsp),
  558.          &yystacksize);
  559. #endif
  560.  
  561.       yyss = yyss1; yyvs = yyvs1;
  562. #ifdef YYLSP_NEEDED
  563.       yyls = yyls1;
  564. #endif
  565. #else /* no yyoverflow */
  566.       /* Extend the stack our own way.  */
  567.       if (yystacksize >= YYMAXDEPTH)
  568.     {
  569.       yyerror("parser stack overflow");
  570.       return 2;
  571.     }
  572.       yystacksize *= 2;
  573.       if (yystacksize > YYMAXDEPTH)
  574.     yystacksize = YYMAXDEPTH;
  575.       yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
  576.       __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
  577.       yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
  578.       __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
  579. #ifdef YYLSP_NEEDED
  580.       yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
  581.       __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
  582. #endif
  583. #endif /* no yyoverflow */
  584.  
  585.       yyssp = yyss + size - 1;
  586.       yyvsp = yyvs + size - 1;
  587. #ifdef YYLSP_NEEDED
  588.       yylsp = yyls + size - 1;
  589. #endif
  590.  
  591. #if YYDEBUG != 0
  592.       if (yydebug)
  593.     fprintf(stderr, "Stack size increased to %d\n", yystacksize);
  594. #endif
  595.  
  596.       if (yyssp >= yyss + yystacksize - 1)
  597.     YYABORT;
  598.     }
  599.  
  600. #if YYDEBUG != 0
  601.   if (yydebug)
  602.     fprintf(stderr, "Entering state %d\n", yystate);
  603. #endif
  604.  
  605.   goto yybackup;
  606.  yybackup:
  607.  
  608. /* Do appropriate processing given the current state.  */
  609. /* Read a lookahead token if we need one and don't already have one.  */
  610. /* yyresume: */
  611.  
  612.   /* First try to decide what to do without reference to lookahead token.  */
  613.  
  614.   yyn = yypact[yystate];
  615.   if (yyn == YYFLAG)
  616.     goto yydefault;
  617.  
  618.   /* Not known => get a lookahead token if don't already have one.  */
  619.  
  620.   /* yychar is either YYEMPTY or YYEOF
  621.      or a valid token in external form.  */
  622.  
  623.   if (yychar == YYEMPTY)
  624.     {
  625. #if YYDEBUG != 0
  626.       if (yydebug)
  627.     fprintf(stderr, "Reading a token: ");
  628. #endif
  629.       yychar = YYLEX;
  630.     }
  631.  
  632.   /* Convert token to internal form (in yychar1) for indexing tables with */
  633.  
  634.   if (yychar <= 0)        /* This means end of input. */
  635.     {
  636.       yychar1 = 0;
  637.       yychar = YYEOF;        /* Don't call YYLEX any more */
  638.  
  639. #if YYDEBUG != 0
  640.       if (yydebug)
  641.     fprintf(stderr, "Now at end of input.\n");
  642. #endif
  643.     }
  644.   else
  645.     {
  646.       yychar1 = YYTRANSLATE(yychar);
  647.  
  648. #if YYDEBUG != 0
  649.       if (yydebug)
  650.     {
  651.       fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
  652.       /* Give the individual parser a way to print the precise meaning
  653.          of a token, for further debugging info.  */
  654. #ifdef YYPRINT
  655.       YYPRINT (stderr, yychar, yylval);
  656. #endif
  657.       fprintf (stderr, ")\n");
  658.     }
  659. #endif
  660.     }
  661.  
  662.   yyn += yychar1;
  663.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  664.     goto yydefault;
  665.  
  666.   yyn = yytable[yyn];
  667.  
  668.   /* yyn is what to do for this token type in this state.
  669.      Negative => reduce, -yyn is rule number.
  670.      Positive => shift, yyn is new state.
  671.        New state is final state => don't bother to shift,
  672.        just return success.
  673.      0, or most negative number => error.  */
  674.  
  675.   if (yyn < 0)
  676.     {
  677.       if (yyn == YYFLAG)
  678.     goto yyerrlab;
  679.       yyn = -yyn;
  680.       goto yyreduce;
  681.     }
  682.   else if (yyn == 0)
  683.     goto yyerrlab;
  684.  
  685.   if (yyn == YYFINAL)
  686.     YYACCEPT;
  687.  
  688.   /* Shift the lookahead token.  */
  689.  
  690. #if YYDEBUG != 0
  691.   if (yydebug)
  692.     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  693. #endif
  694.  
  695.   /* Discard the token being shifted unless it is eof.  */
  696.   if (yychar != YYEOF)
  697.     yychar = YYEMPTY;
  698.  
  699.   *++yyvsp = yylval;
  700. #ifdef YYLSP_NEEDED
  701.   *++yylsp = yylloc;
  702. #endif
  703.  
  704.   /* count tokens shifted since error; after three, turn off error status.  */
  705.   if (yyerrstatus) yyerrstatus--;
  706.  
  707.   yystate = yyn;
  708.   goto yynewstate;
  709.  
  710. /* Do the default action for the current state.  */
  711. yydefault:
  712.  
  713.   yyn = yydefact[yystate];
  714.   if (yyn == 0)
  715.     goto yyerrlab;
  716.  
  717. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  718. yyreduce:
  719.   yylen = yyr2[yyn];
  720.   if (yylen > 0)
  721.     yyval = yyvsp[1-yylen]; /* implement default value of the action */
  722.  
  723. #if YYDEBUG != 0
  724.   if (yydebug)
  725.     {
  726.       int i;
  727.  
  728.       fprintf (stderr, "Reducing via rule %d (line %d), ",
  729.            yyn, yyrline[yyn]);
  730.  
  731.       /* Print the symbols being reduced, and their result.  */
  732.       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
  733.     fprintf (stderr, "%s ", yytname[yyrhs[i]]);
  734.       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
  735.     }
  736. #endif
  737.  
  738.  
  739.   switch (yyn) {
  740.  
  741. case 2:
  742. #line 97 "/usr/local/ls6/src+data/src/freeWAIS-sf/ir/field_y.y"
  743. {
  744.   /* $<sval>2;                     dont inclemet this! (up) */
  745.   number_of_regexp += insert_regexp(yyvsp[0].sval+1, number_of_regexp, &gregexp_pos);
  746.   /* Hey tung: if you duplicat the regexp, free it here ! (up) */
  747.   s_free(yyvsp[0].sval);
  748.   put_record_end_Ltable(gregexp_pos);
  749. ;
  750.     break;}
  751. case 4:
  752. #line 108 "/usr/local/ls6/src+data/src/freeWAIS-sf/ir/field_y.y"
  753. {layout_specified = 1;;
  754.     break;}
  755. case 7:
  756. #line 116 "/usr/local/ls6/src+data/src/freeWAIS-sf/ir/field_y.y"
  757. {
  758.   /* $1 is never used. So don't copy the string in yylex! */
  759.   long begin_tag_pos, date_begin_tag_pos;
  760.   /* $<sval>2;                     Hey tung: no increment! who frees? (up) */
  761.   /* $<sval>3; */
  762.   if(yyvsp[0].sval != NULL) {
  763.     /* ++($<sval>7); ok tung (up) */
  764.     number_of_regexp += insert_regexp(yyvsp[0].sval+1, number_of_regexp,
  765.                       &date_begin_tag_pos);
  766.   }
  767.   else date_begin_tag_pos = -1;
  768.   number_of_regexp += insert_regexp(yyvsp[-5].sval+1,number_of_regexp,&begin_tag_pos);
  769.   put_hdate_ltable(begin_tag_pos, yyvsp[-4].sval+1, yyvsp[-3].sval, 
  770.                    yyvsp[-2].sval, yyvsp[-1].sval, date_begin_tag_pos);
  771.   s_free(yyvsp[-5].sval);             /* (up) */
  772.   s_free(yyvsp[-4].sval);             /* (up) */
  773.   if (yyvsp[0].sval != NULL) s_free(yyvsp[0].sval); /* (up) */
  774. ;
  775.     break;}
  776. case 8:
  777. #line 135 "/usr/local/ls6/src+data/src/freeWAIS-sf/ir/field_y.y"
  778. {
  779.   long hline_begin_tag_pos, begin_tag_pos, end_tag_pos;
  780.   /* $<sval>2;                     oh tung! (up) */
  781.   /* $<sval>3; */
  782.   if(yyvsp[0].sval != NULL) {
  783.     /* ++($<sval>5); */
  784.     number_of_regexp += insert_regexp(yyvsp[0].sval+1,number_of_regexp,&hline_begin_tag_pos);
  785.   }
  786.   else hline_begin_tag_pos = -1;
  787.   number_of_regexp += insert_regexp(yyvsp[-3].sval+1,number_of_regexp,&begin_tag_pos);
  788.   number_of_regexp += insert_regexp(yyvsp[-2].sval+1, number_of_regexp, &end_tag_pos);
  789.   put_headline(begin_tag_pos, end_tag_pos, hline_begin_tag_pos, 
  790.            yyvsp[-1].ival, offset, number_of_headlines);
  791.   offset += yyvsp[-1].ival+1;
  792.   ++number_of_headlines;
  793.   s_free(yyvsp[-3].sval);
  794.   s_free(yyvsp[-2].sval);
  795.   if (yyvsp[0].sval != NULL) s_free(yyvsp[0].sval); /* (up) */
  796. ;
  797.     break;}
  798. case 11:
  799. #line 160 "/usr/local/ls6/src+data/src/freeWAIS-sf/ir/field_y.y"
  800. {
  801.   /* insert begin_tag */
  802.   /* ($<sval>2)++;     oh tung! (up) */
  803.   number_of_regexp += insert_regexp(yyvsp[-1].sval+1, number_of_regexp, &gregexp_pos);
  804.   if(yyvsp[0].sval != NULL) {
  805.     /*  ($<sval>3)++;     oh tung! (up) */
  806.     number_of_regexp += insert_regexp(yyvsp[0].sval+1, number_of_regexp, &index_pos);
  807.   }
  808.   else index_pos = -1;
  809. ;
  810.     break;}
  811. case 12:
  812. #line 171 "/usr/local/ls6/src+data/src/freeWAIS-sf/ir/field_y.y"
  813. {
  814.   if(fieldlist_not_empty == 0) {
  815.     if(save_index_fields(NULL, &number_of_index_fields, &gfield_id)) {
  816.       make_index_fields(number_of_index_fields);
  817.       put_index_fields(NULL, NULL, gfield_id, gregexp_pos, index_pos, 0);
  818.     }
  819.     else put_index_fields(NULL, NULL, gfield_id, gregexp_pos, index_pos, 1);
  820.   }
  821. ;
  822.     break;}
  823. case 13:
  824. #line 183 "/usr/local/ls6/src+data/src/freeWAIS-sf/ir/field_y.y"
  825. {
  826.   if(!fieldlist_not_empty && !options_not_empty && !indexspecs_not_empty) {
  827.     long pos;
  828.     /* ($<sval>10)++;                   oh tung! (up)  */
  829.     make_ntable(&pos);
  830.     number_of_regexp += insert_regexp(yyvsp[-8].sval+1, number_of_regexp,&gregexp_pos);
  831.     Ntable->begin_tag_pos[pos] = gregexp_pos;
  832.     number_of_regexp += insert_regexp(yyvsp[0].sval+1, number_of_regexp,&gregexp_pos);
  833.     Ntable->end_tag_pos[pos] = gregexp_pos;
  834.     Ntable->position += 1;
  835.   }
  836.   else if(!fieldlist_not_empty && !options_not_empty && indexspecs_not_empty) {
  837.     /* ++($<sval>10); oh tung! (up)  */
  838.     number_of_regexp += insert_regexp(yyvsp[0].sval+1,number_of_regexp,&gregexp_pos);
  839.     put_end_tag_ftable(gfield_id, gregexp_pos);
  840.     global_dct_exists = true;
  841.     number_of_indextypes = 0;
  842.     fieldlist_not_empty = 0;
  843.     options_not_empty = 0;
  844.     indexspecs_not_empty = 0;
  845.     regexp_not_empty = 0;
  846.   }
  847.   else {
  848.     long i, j, k;
  849.     long field_id;
  850.     long begin_tag_pos = gregexp_pos; /* save old value of gregexp_pos */
  851.     /* ++($<sval>10);; oh tung! (up)  */
  852.     number_of_regexp += insert_regexp(yyvsp[0].sval+1,number_of_regexp,&gregexp_pos);
  853.     if(number_of_fields_inserted > 1) {
  854.       for(i=0; i< number_of_fields_inserted; i++) {
  855.         field_id = field_id_set[i];
  856.         put_end_tag_ftable(field_id, gregexp_pos);
  857.     if(index_kind_both) {   
  858.       put_tags_in_gdb(field_id, begin_tag_pos, gregexp_pos, 
  859.               index_pos, &index_kind_both, &number_of_index_fields);
  860.  
  861.     } 
  862.       }
  863.       s_free(field_id_set);
  864.     }
  865.     else {
  866.       put_end_tag_ftable(gfield_id, gregexp_pos);
  867.       if(index_kind_both) {   
  868.     put_tags_in_gdb(gfield_id, begin_tag_pos, gregexp_pos, 
  869.             index_pos, &index_kind_both, &number_of_index_fields);
  870.     
  871.       }
  872.     } 
  873.     if(is_headline) {
  874.       put_headline(-1, gregexp_pos, -1, 0, offset, number_of_headlines);
  875.       ++number_of_headlines;
  876.       is_headline = 0;
  877.     }
  878.     number_of_fields_inserted = 0;
  879.     number_of_indextypes = 0;
  880.     fieldlist_not_empty = 0;
  881.     options_not_empty = 0;
  882.     indexspecs_not_empty = 0;
  883.     regexp_not_empty = 0;
  884.   }
  885.   s_free(yyvsp[-8].sval);             /* (up) */
  886.   s_free(yyvsp[0].sval);            /* (up) */
  887.   if (yyvsp[-7].sval != NULL) s_free(yyvsp[-7].sval); /* (up) */
  888. ;
  889.     break;}
  890. case 15:
  891. #line 250 "/usr/local/ls6/src+data/src/freeWAIS-sf/ir/field_y.y"
  892. {
  893.   options_not_empty = 1;
  894.   yyval.sval = yyvsp[0].sval;
  895. ;
  896.     break;}
  897. case 16:
  898. #line 256 "/usr/local/ls6/src+data/src/freeWAIS-sf/ir/field_y.y"
  899.   long i, field_id;
  900.  
  901.   if(yyvsp[-1].sval != NULL) {
  902.     /* ++($<sval>2); */
  903.     number_of_regexp += insert_regexp(yyvsp[-1].sval+1, number_of_regexp,&index_pos);
  904.   }
  905.   else index_pos = -1;
  906.   if(number_of_fields_inserted > 1) {
  907.    for(i=0; i< number_of_fields_inserted; i++) {
  908.     field_id = field_id_set[i];
  909.     put_numeric_ftable(index_pos, yyvsp[0].ival, field_id);
  910.     save_numeric_index_fields(field_id);
  911.    }
  912.   }
  913.   else {put_numeric_ftable(index_pos, yyvsp[0].ival, gfield_id);
  914.     save_numeric_index_fields(gfield_id);}
  915.   if (yyvsp[-1].sval != NULL) s_free(yyvsp[-1].sval); /* (up) */
  916. ;
  917.     break;}
  918. case 17:
  919. #line 276 "/usr/local/ls6/src+data/src/freeWAIS-sf/ir/field_y.y"
  920. {
  921.   long i;
  922.   long field_id;
  923.   if(number_of_fields_inserted > 1) {
  924.    for(i=0; i< number_of_fields_inserted; i++) {
  925.     field_id = field_id_set[i]; 
  926.     index_fields[field_id]->stemming = true;
  927.    }
  928.   }
  929.   else index_fields[gfield_id]->stemming = true;
  930. ;
  931.     break;}
  932. case 18:
  933. #line 288 "/usr/local/ls6/src+data/src/freeWAIS-sf/ir/field_y.y"
  934. {
  935.   long fpos = index_fields[gfield_id]->number_of_Ftable;
  936.   long regexp_pos = index_fields[gfield_id]->Ftable[fpos].begin_tag_pos;
  937.   if(layout_specified) {
  938.     fprintf(stderr,"syntax error!\nlayout has been specified\n");
  939.     return(1);
  940.   }
  941.   if(yyvsp[-1].sval != NULL) {
  942.     ++(yyvsp[-1].sval);
  943.     number_of_regexp += insert_regexp(yyvsp[-1].sval, number_of_regexp,&gregexp_pos);
  944.   }
  945.   else gregexp_pos = -1;
  946.   put_headline(regexp_pos, -1, gregexp_pos, yyvsp[0].ival, offset,
  947.                number_of_headlines);
  948.   offset += yyvsp[0].ival+1;
  949.   is_headline = 1;
  950. ;
  951.     break;}
  952. case 19:
  953. #line 306 "/usr/local/ls6/src+data/src/freeWAIS-sf/ir/field_y.y"
  954. {
  955.   /* $1 is never used. So don't copy the string in yylex! */
  956.   long regexp_pos1, regexp_pos2;
  957.   if(layout_specified) {
  958.     fprintf(stderr,"syntax error!\nlayout has been specified\n");
  959.     return(1);
  960.   }
  961.   /* ++($<sval>2); ++($<sval>3); hey tung (up) */
  962.   number_of_regexp += insert_regexp(yyvsp[-5].sval+1, number_of_regexp, ®exp_pos1);
  963.   if(yyvsp[0].sval != NULL) {
  964.     /* ++($<sval>7); (up) */
  965.     number_of_regexp += insert_regexp(yyvsp[0].sval+1,number_of_regexp, ®exp_pos2);
  966.   }
  967.   else regexp_pos2 = -1;
  968.   put_hdate_ltable(regexp_pos1, yyvsp[-4].sval+1, yyvsp[-3].sval, 
  969.                    yyvsp[-2].sval, yyvsp[-1].sval, regexp_pos2);
  970.   s_free(yyvsp[-5].sval);             /* (up) */
  971.   s_free(yyvsp[-4].sval);             /* (up) */
  972.   if (yyvsp[0].sval != NULL) s_free(yyvsp[0].sval); /* (up) */
  973. ;
  974.     break;}
  975. case 20:
  976. #line 327 "/usr/local/ls6/src+data/src/freeWAIS-sf/ir/field_y.y"
  977. {/* regexp_not_empty = 0; (up)*/ yyval.sval = NULL; /* oh tung! what are return values for? (up) */ ;
  978.     break;}
  979. case 21:
  980. #line 328 "/usr/local/ls6/src+data/src/freeWAIS-sf/ir/field_y.y"
  981. {/* regexp_not_empty = 1; (up)*/yyval.sval =yyvsp[0].sval; /* (up) */;
  982.     break;}
  983. case 23:
  984. #line 332 "/usr/local/ls6/src+data/src/freeWAIS-sf/ir/field_y.y"
  985. {
  986.   indexspecs_not_empty = 1;
  987.   yyval.sval = yyvsp[0].sval;
  988. ;
  989.     break;}
  990. case 24:
  991. #line 338 "/usr/local/ls6/src+data/src/freeWAIS-sf/ir/field_y.y"
  992. {
  993.   long i;
  994.   long field_id;
  995.   /* tung: it's no good style to pass the strings from yylex!
  996.      why not use the tokens ? */
  997.   if(number_of_fields_inserted > 1) {
  998.     for(i=0; i<number_of_fields_inserted; i++) {
  999.       field_id = field_id_set[i];
  1000.       put_indextypes(yyvsp[-1].sval, index_kind,
  1001.              field_id,number_of_indextypes);
  1002.     }
  1003.   }
  1004.   else put_indextypes(yyvsp[-1].sval, index_kind,
  1005.               gfield_id,number_of_indextypes);
  1006.   ++number_of_indextypes;
  1007.   s_free(yyvsp[-1].sval);
  1008. ;
  1009.     break;}
  1010. case 28:
  1011. #line 361 "/usr/local/ls6/src+data/src/freeWAIS-sf/ir/field_y.y"
  1012. {               
  1013.   if(fieldlist_not_empty) {
  1014.     fprintf(stderr,"warning: creating fields use variable LOCAL but not GLOBAL!!!\n");
  1015.     index_kind = 1;
  1016.   } else {
  1017.     index_kind = 0; 
  1018.     global_dct_exists = true;
  1019.   }
  1020. ;
  1021.     break;}
  1022. case 29:
  1023. #line 371 "/usr/local/ls6/src+data/src/freeWAIS-sf/ir/field_y.y"
  1024. {
  1025.   if(fieldlist_not_empty == 0) {
  1026.     fprintf(stderr,"warning: creating global database use variable GLOBAL but not LOCAL!!!\n");
  1027.     index_kind = 0; 
  1028.     global_dct_exists = true;
  1029.   } else {
  1030.     index_kind = 1;
  1031.   }
  1032. ;
  1033.     break;}
  1034. case 30:
  1035. #line 381 "/usr/local/ls6/src+data/src/freeWAIS-sf/ir/field_y.y"
  1036. {
  1037.   if(fieldlist_not_empty == 0) {
  1038.     fprintf(stderr,"warning: creating global database use variable GLOBAL but not BOTH or missing field name!!!\n");
  1039.     index_kind = 0; 
  1040.     global_dct_exists = true;
  1041.   } else {
  1042.     index_kind = 2; global_dct_exists = true; index_kind_both = true;
  1043.   }
  1044. ;
  1045.     break;}
  1046. case 31:
  1047. #line 392 "/usr/local/ls6/src+data/src/freeWAIS-sf/ir/field_y.y"
  1048. {      /* $1 is nwer used! so dont duplicate it in yytext ! (up) */ ;
  1049.     break;}
  1050. case 32:
  1051. #line 394 "/usr/local/ls6/src+data/src/freeWAIS-sf/ir/field_y.y"
  1052. { /* $1 is nwer used! so dont duplicate it in yytext ! (up) */
  1053. /*
  1054.   if($<sval>2 != NULL)
  1055.     if(Ltable != NULL)
  1056.       Ltable->month_is_string = 1;
  1057. */
  1058. ;
  1059.     break;}
  1060. case 33:
  1061. #line 401 "/usr/local/ls6/src+data/src/freeWAIS-sf/ir/field_y.y"
  1062. {      /* $1 is nwer used! so dont duplicate it in yytext ! (up) */ ;
  1063.     break;}
  1064. case 35:
  1065. #line 404 "/usr/local/ls6/src+data/src/freeWAIS-sf/ir/field_y.y"
  1066. {      /* $1 is nwer used! so dont duplicate it in yytext ! (up) */
  1067.   if(yyvsp[0].sval != NULL)
  1068.     if(Ltable != NULL)
  1069.       Ltable->month_is_string = 1;
  1070.  
  1071. ;
  1072.     break;}
  1073. case 36:
  1074. #line 412 "/usr/local/ls6/src+data/src/freeWAIS-sf/ir/field_y.y"
  1075. {yyval.sval = NULL;;
  1076.     break;}
  1077. case 37:
  1078. #line 413 "/usr/local/ls6/src+data/src/freeWAIS-sf/ir/field_y.y"
  1079. {yyval.sval = yyvsp[0].sval;;
  1080.     break;}
  1081. case 39:
  1082. #line 418 "/usr/local/ls6/src+data/src/freeWAIS-sf/ir/field_y.y"
  1083. {
  1084.   ++number_of_fields_inserted;
  1085.   if(number_of_fields_inserted > 1) {
  1086.     if(field_id_set == NULL) {
  1087.       field_id_set = (long*)s_malloc((size_t)(sizeof(long) * 5));
  1088.       field_id_set[0] = gfield_id;
  1089.     }
  1090.     else {
  1091.       if(number_of_fields_inserted >= 5) {
  1092.         field_id_set = (long*)
  1093.           s_realloc(field_id_set,
  1094.                     (size_t)(sizeof(long) * (number_of_fields_inserted + 5)));
  1095.       }
  1096.     }
  1097.   }
  1098.   if(save_index_fields(yyvsp[-2].sval,&number_of_index_fields,&gfield_id)) {
  1099.     make_index_fields(number_of_index_fields);
  1100.     put_index_fields(yyvsp[-2].sval, yyvsp[-1].sval, gfield_id, gregexp_pos, index_pos, 0);
  1101.   }
  1102.   else put_index_fields(yyvsp[-2].sval, yyvsp[-1].sval, gfield_id, gregexp_pos, index_pos, 1);
  1103.   if(number_of_fields_inserted == 2)
  1104.     field_id_set[1] = gfield_id;
  1105.   else if(number_of_fields_inserted > 2)
  1106.     field_id_set[number_of_fields_inserted-1] = gfield_id;
  1107.   fieldlist_not_empty = 1;
  1108.   yyval.sval = yyvsp[0].sval;
  1109.   s_free(yyvsp[-2].sval);             /* (up) */
  1110.   s_free(yyvsp[-1].sval);             /* (up) */
  1111. ;
  1112.     break;}
  1113. }
  1114.    /* the action file gets copied in in place of this dollarsign */
  1115. #line 465 "/usr/local/gnulang-94a/lib/bison.simple"
  1116.  
  1117.   yyvsp -= yylen;
  1118.   yyssp -= yylen;
  1119. #ifdef YYLSP_NEEDED
  1120.   yylsp -= yylen;
  1121. #endif
  1122.  
  1123. #if YYDEBUG != 0
  1124.   if (yydebug)
  1125.     {
  1126.       short *ssp1 = yyss - 1;
  1127.       fprintf (stderr, "state stack now");
  1128.       while (ssp1 != yyssp)
  1129.     fprintf (stderr, " %d", *++ssp1);
  1130.       fprintf (stderr, "\n");
  1131.     }
  1132. #endif
  1133.  
  1134.   *++yyvsp = yyval;
  1135.  
  1136. #ifdef YYLSP_NEEDED
  1137.   yylsp++;
  1138.   if (yylen == 0)
  1139.     {
  1140.       yylsp->first_line = yylloc.first_line;
  1141.       yylsp->first_column = yylloc.first_column;
  1142.       yylsp->last_line = (yylsp-1)->last_line;
  1143.       yylsp->last_column = (yylsp-1)->last_column;
  1144.       yylsp->text = 0;
  1145.     }
  1146.   else
  1147.     {
  1148.       yylsp->last_line = (yylsp+yylen-1)->last_line;
  1149.       yylsp->last_column = (yylsp+yylen-1)->last_column;
  1150.     }
  1151. #endif
  1152.  
  1153.   /* Now "shift" the result of the reduction.
  1154.      Determine what state that goes to,
  1155.      based on the state we popped back to
  1156.      and the rule number reduced by.  */
  1157.  
  1158.   yyn = yyr1[yyn];
  1159.  
  1160.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  1161.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  1162.     yystate = yytable[yystate];
  1163.   else
  1164.     yystate = yydefgoto[yyn - YYNTBASE];
  1165.  
  1166.   goto yynewstate;
  1167.  
  1168. yyerrlab:   /* here on detecting error */
  1169.  
  1170.   if (! yyerrstatus)
  1171.     /* If not already recovering from an error, report this error.  */
  1172.     {
  1173.       ++yynerrs;
  1174.  
  1175. #ifdef YYERROR_VERBOSE
  1176.       yyn = yypact[yystate];
  1177.  
  1178.       if (yyn > YYFLAG && yyn < YYLAST)
  1179.     {
  1180.       int size = 0;
  1181.       char *msg;
  1182.       int x, count;
  1183.  
  1184.       count = 0;
  1185.       /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
  1186.       for (x = (yyn < 0 ? -yyn : 0);
  1187.            x < (sizeof(yytname) / sizeof(char *)); x++)
  1188.         if (yycheck[x + yyn] == x)
  1189.           size += strlen(yytname[x]) + 15, count++;
  1190.       msg = (char *) malloc(size + 15);
  1191.       if (msg != 0)
  1192.         {
  1193.           strcpy(msg, "parse error");
  1194.  
  1195.           if (count < 5)
  1196.         {
  1197.           count = 0;
  1198.           for (x = (yyn < 0 ? -yyn : 0);
  1199.                x < (sizeof(yytname) / sizeof(char *)); x++)
  1200.             if (yycheck[x + yyn] == x)
  1201.               {
  1202.             strcat(msg, count == 0 ? ", expecting `" : " or `");
  1203.             strcat(msg, yytname[x]);
  1204.             strcat(msg, "'");
  1205.             count++;
  1206.               }
  1207.         }
  1208.           yyerror(msg);
  1209.           free(msg);
  1210.         }
  1211.       else
  1212.         yyerror ("parse error; also virtual memory exceeded");
  1213.     }
  1214.       else
  1215. #endif /* YYERROR_VERBOSE */
  1216.     yyerror("parse error");
  1217.     }
  1218.  
  1219.   goto yyerrlab1;
  1220. yyerrlab1:   /* here on error raised explicitly by an action */
  1221.  
  1222.   if (yyerrstatus == 3)
  1223.     {
  1224.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  1225.  
  1226.       /* return failure if at end of input */
  1227.       if (yychar == YYEOF)
  1228.     YYABORT;
  1229.  
  1230. #if YYDEBUG != 0
  1231.       if (yydebug)
  1232.     fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  1233. #endif
  1234.  
  1235.       yychar = YYEMPTY;
  1236.     }
  1237.  
  1238.   /* Else will try to reuse lookahead token
  1239.      after shifting the error token.  */
  1240.  
  1241.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  1242.  
  1243.   goto yyerrhandle;
  1244.  
  1245. yyerrdefault:  /* current state does not do anything special for the error token. */
  1246.  
  1247. #if 0
  1248.   /* This is wrong; only states that explicitly want error tokens
  1249.      should shift them.  */
  1250.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  1251.   if (yyn) goto yydefault;
  1252. #endif
  1253.  
  1254. yyerrpop:   /* pop the current state because it cannot handle the error token */
  1255.  
  1256.   if (yyssp == yyss) YYABORT;
  1257.   yyvsp--;
  1258.   yystate = *--yyssp;
  1259. #ifdef YYLSP_NEEDED
  1260.   yylsp--;
  1261. #endif
  1262.  
  1263. #if YYDEBUG != 0
  1264.   if (yydebug)
  1265.     {
  1266.       short *ssp1 = yyss - 1;
  1267.       fprintf (stderr, "Error: state stack now");
  1268.       while (ssp1 != yyssp)
  1269.     fprintf (stderr, " %d", *++ssp1);
  1270.       fprintf (stderr, "\n");
  1271.     }
  1272. #endif
  1273.  
  1274. yyerrhandle:
  1275.  
  1276.   yyn = yypact[yystate];
  1277.   if (yyn == YYFLAG)
  1278.     goto yyerrdefault;
  1279.  
  1280.   yyn += YYTERROR;
  1281.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  1282.     goto yyerrdefault;
  1283.  
  1284.   yyn = yytable[yyn];
  1285.   if (yyn < 0)
  1286.     {
  1287.       if (yyn == YYFLAG)
  1288.     goto yyerrpop;
  1289.       yyn = -yyn;
  1290.       goto yyreduce;
  1291.     }
  1292.   else if (yyn == 0)
  1293.     goto yyerrpop;
  1294.  
  1295.   if (yyn == YYFINAL)
  1296.     YYACCEPT;
  1297.  
  1298. #if YYDEBUG != 0
  1299.   if (yydebug)
  1300.     fprintf(stderr, "Shifting error token, ");
  1301. #endif
  1302.  
  1303.   *++yyvsp = yylval;
  1304. #ifdef YYLSP_NEEDED
  1305.   *++yylsp = yylloc;
  1306. #endif
  1307.  
  1308.   yystate = yyn;
  1309.   goto yynewstate;
  1310. }
  1311. #line 448 "/usr/local/ls6/src+data/src/freeWAIS-sf/ir/field_y.y"
  1312.  
  1313. extern FILE* yyin;
  1314. extern int yylineno;
  1315. extern char yytext[];
  1316. extern int yydebug;
  1317.  
  1318.  
  1319. yyerror(s)
  1320. char *s;
  1321. {
  1322.    fprintf(stderr,"line %d: syntax error at or near string \"%s\"\n",
  1323.            yylineno, yytext);
  1324.    fprintf(stderr,"%s\n", s);
  1325. }
  1326.  
  1327. yywrap()
  1328. {
  1329.    return(1);
  1330. }
  1331.  
  1332. static void clear_regexp(number_of_elements)
  1333.      long number_of_elements;
  1334. {
  1335.   long i;
  1336.   for(i=0; i< number_of_elements; i++) 
  1337.     s_free(regexp_set[i]);
  1338.   s_free(regexp_set);
  1339. }
  1340.  
  1341. /* ------------------------------------------------------------- */
  1342.  
  1343. static void make_ntable(pos)
  1344.      long *pos;
  1345. {
  1346.   if(Ntable == NULL) {
  1347.     Ntable = (nidx_table*)s_malloc((size_t)sizeof(nidx_table));
  1348.     Ntable->position = 0;
  1349.   }
  1350.   *pos = Ntable->position;
  1351.   if(Ntable->begin_tag_pos == NULL && Ntable->end_tag_pos == NULL) {
  1352.     Ntable->begin_tag_pos = (long*)s_malloc((size_t)(sizeof(long)));
  1353.     Ntable->end_tag_pos = (long*)s_malloc((size_t)(sizeof(long)));
  1354.   }
  1355.   else {
  1356.     Ntable->begin_tag_pos =
  1357.       (long*)s_realloc(Ntable->begin_tag_pos, 
  1358.                        (size_t)(sizeof(long) * (Ntable->position + 1)));
  1359.     Ntable->end_tag_pos = 
  1360.       (long*)s_realloc(Ntable->end_tag_pos, 
  1361.                        (size_t)(sizeof(long) * (Ntable->position + 1)));
  1362.   }
  1363. }
  1364.  
  1365. /* ------------------------------------------------------------- */
  1366.  
  1367. static void make_index_fields(number_of_elements)
  1368.      long number_of_elements;
  1369. {
  1370.   long i;
  1371.  
  1372.   if(index_fields == NULL) {
  1373.     index_fields = (fields_struct**)s_malloc((size_t)sizeof(fields_struct*));
  1374.     /* (up) initialize it - when you rely on zero filled records */
  1375.     bzero(index_fields,(size_t)sizeof(fields_struct*));
  1376.   } else { 
  1377.     index_fields = 
  1378.       (fields_struct**)s_realloc(index_fields,
  1379.                                  (size_t)(sizeof(fields_struct*) * 
  1380.                                           number_of_elements));
  1381.     /* (up) initialize it - when you rely on zero filled records */
  1382.     bzero(&(index_fields[number_of_elements-1]),(size_t)sizeof(fields_struct*));
  1383.   }
  1384.   for(i=0; i < number_of_elements; i++) {
  1385.     if(index_fields[i] == NULL) {
  1386.       index_fields[i] = (fields_struct*)s_malloc((size_t)sizeof(fields_struct));
  1387.       /* (up) initialize it - when you rely on zero filled records */
  1388.       bzero(index_fields[i],(size_t)sizeof(fields_struct));
  1389.     }
  1390.   }
  1391.   return;                       /* up: redundant */
  1392. }
  1393. /* ------------------------------------------------------------- */
  1394.  
  1395. static void put_end_tag_ftable(field_id, regexp_pos)
  1396.      long field_id;
  1397.      long regexp_pos;
  1398. {
  1399.   long fpos = index_fields[field_id]->number_of_Ftable;
  1400.   index_fields[field_id]->Ftable[fpos].end_tag_pos = regexp_pos;
  1401.   index_fields[field_id]->number_of_Ftable += 1;
  1402. }
  1403.  
  1404. /* ------------------------------------------------------------- */
  1405.  
  1406. static void put_indextypes(itype, i_kind, field_id, ipos)
  1407.      char* itype;
  1408.      int i_kind;
  1409.      long field_id;
  1410.      long ipos;
  1411. {
  1412.   long len = strlen(itype);
  1413.   long fpos = index_fields[field_id]->number_of_Ftable;
  1414.  
  1415.   if(index_fields[field_id]->Ftable[fpos].indextypes == NULL) {
  1416.     index_fields[field_id]->Ftable[fpos].indextypes =
  1417.       (char**)s_malloc((size_t)(sizeof(char*) * NUMBER_OF_INDEXTYPES));
  1418.     index_fields[field_id]->Ftable[fpos].index_kind =
  1419.       (int*)s_malloc((size_t)(sizeof(int) * NUMBER_OF_INDEXTYPES));
  1420.   }
  1421.   index_fields[field_id]->Ftable[fpos].indextypes[ipos] =
  1422.     (char*)s_malloc((size_t)(sizeof(char) * (len + 2)));
  1423.   s_strncpy(index_fields[field_id]->Ftable[fpos].indextypes[ipos],
  1424.             itype, len + 1);
  1425.   index_fields[field_id]->Ftable[fpos].index_kind[ipos] = i_kind;
  1426. }
  1427. /* ------------------------------------------------------------- */
  1428.  
  1429. static void put_index_fields(field_name, field_description,
  1430.                              field_id, regexp_pos, index_pos, field_exists)
  1431.      char* field_name;
  1432.      char* field_description;
  1433.      long field_id;
  1434.      long regexp_pos;
  1435.      long index_pos;
  1436.      boolean field_exists;
  1437. {
  1438.   long fpos, flen;
  1439.   
  1440.   if(index_fields[field_id]->Ftable == NULL) {
  1441.     index_fields[field_id]->Ftable =
  1442.       (ftable*)s_malloc((size_t)sizeof(ftable));
  1443.     fpos = index_fields[field_id]->number_of_Ftable;
  1444.   }
  1445.   else {
  1446.     index_fields[field_id]->Ftable = (ftable*)
  1447.       s_realloc(index_fields[field_id]->Ftable,
  1448.                 (size_t)(sizeof(ftable) * (index_fields[field_id]->number_of_Ftable + 1)));
  1449.     /* Tung, please: initialize memory if you rely on zero's (up) */
  1450.     bzero(index_fields[field_id]->Ftable
  1451.             + index_fields[field_id]->number_of_Ftable,
  1452.           sizeof(ftable));
  1453.     fpos = index_fields[field_id]->number_of_Ftable;
  1454.   }
  1455.   if(field_exists == 0) {
  1456.     if(field_name == NULL) {
  1457.       index_fields[field_id]->field_name = NULL;
  1458.       index_fields[field_id]->n_index_pos = -1;
  1459.     }
  1460.     else {
  1461.       flen = strlen(field_name);
  1462.       index_fields[field_id]->field_name = /* who frees this ? (up) */
  1463.         (char*)s_malloc((size_t)(sizeof(char) * (flen + 2)));
  1464.       s_strncpy(index_fields[field_id]->field_name, field_name, flen+1);
  1465.       if (field_description) {
  1466.           if (index_fields[field_id]->field_description) s_free(index_fields[field_id]->field_description);
  1467.           index_fields[field_id]->field_description = strdup(field_description);
  1468.       }
  1469.       index_fields[field_id]->field_id = field_id;
  1470.       index_fields[field_id]->n_index_pos = -1;
  1471.     }
  1472.     index_fields[field_id]->numeric = 0;
  1473.   }
  1474.   index_fields[field_id]->Ftable[fpos].begin_tag_pos = regexp_pos;
  1475.   index_fields[field_id]->Ftable[fpos].index_pos = index_pos;
  1476. }
  1477. /* ------------------------------------------------------------- */
  1478.  
  1479. static void put_numeric_ftable(n_index_pos, n_len, field_id)
  1480.      long n_index_pos;
  1481.      int n_len;
  1482.      long field_id;
  1483. {
  1484.   long len;
  1485.   
  1486.   index_fields[field_id]->numeric = 1;
  1487.   if(n_index_pos > -1) 
  1488.     index_fields[field_id]->n_index_pos = n_index_pos;
  1489.   else index_fields[field_id]->n_index_pos = -1;
  1490.   index_fields[field_id]->numeric_len = n_len;
  1491. }
  1492.  
  1493. /* ------------------------------------------------------------- */
  1494.  
  1495. static void put_tags_in_gdb(field_id, begin_tag_pos, end_tag_pos, 
  1496.                 index_pos, both, number_of_index_fields)
  1497.      long field_id;
  1498.      long begin_tag_pos;
  1499.      long end_tag_pos;
  1500.      long index_pos;
  1501.      long *number_of_index_fields;
  1502.      boolean *both;
  1503. {
  1504.   long j, k;
  1505.   long indextypes_number = 0;
  1506.   long field_id_of_gdb;
  1507.   
  1508.   *both = false;
  1509.   j = index_fields[field_id]->number_of_Ftable - 1 ; 
  1510.   
  1511.   for(k=0; k < NUMBER_OF_INDEXTYPES; k++) {
  1512.     if(index_fields[field_id]->Ftable[j].indextypes[k] != NULL) {
  1513.       if(index_fields[field_id]->Ftable[j].index_kind[k] == 2) {
  1514.     if(save_index_fields(NULL, number_of_index_fields, &field_id_of_gdb)) {
  1515.       make_index_fields(*number_of_index_fields);
  1516.       put_index_fields(NULL, NULL, field_id_of_gdb, begin_tag_pos, index_pos, 0);
  1517.     } else put_index_fields(NULL, NULL, field_id_of_gdb, begin_tag_pos, index_pos, 1);
  1518.     put_indextypes(index_fields[field_id]->Ftable[j].indextypes[k],
  1519.                0, field_id_of_gdb, indextypes_number);
  1520.     ++indextypes_number;
  1521.     *both = true;
  1522.       }
  1523.     } else break;
  1524.   }
  1525.   if(*both) {
  1526.     put_end_tag_ftable(field_id_of_gdb, end_tag_pos);
  1527.     *both = false;
  1528.   }
  1529.  
  1530. /* ------------------------------------------------------------- */
  1531.  
  1532. static void put_headline(begin_tag_pos, end_tag_pos, hline_begin_tag_pos, n_len, n_offset, number_of_elements)
  1533.      long begin_tag_pos;
  1534.      long end_tag_pos;
  1535.      long hline_begin_tag_pos;
  1536.      long n_len;
  1537.      long n_offset;
  1538.      long number_of_elements;
  1539. {
  1540.   long i;
  1541.   
  1542.   if(Ltable == NULL) {
  1543.     Ltable = (ltable*)s_malloc((size_t)sizeof(ltable));
  1544.     Ltable->date_begin_tag_pos = -1;
  1545.     Ltable->date_tag_pos = -1;
  1546.   }
  1547.   if(Ltable->layout == NULL) {
  1548.     Maxhealine = Nheadline + 5;
  1549.     Ltable->layout = 
  1550.       (layout_struct*)s_malloc((size_t)(sizeof(layout_struct) * Maxhealine));
  1551.     for(i=0; i<Maxhealine; i++)
  1552.       Ltable->layout[i].hline_begin_tag_pos = -1;
  1553.   }
  1554.   else {
  1555.     if(end_tag_pos > -1 && Nheadline == Maxhealine) {
  1556.       Maxhealine = Nheadline + 5;
  1557.       Ltable->layout = (layout_struct*)
  1558.         s_realloc(Ltable->layout, (sizeof(layout_struct) * Maxhealine));
  1559.       for(i= Nheadline; i<Maxhealine; i++)
  1560.         Ltable->layout[i].hline_begin_tag_pos = -1;
  1561.     }
  1562.   }
  1563.   if(end_tag_pos > -1 && begin_tag_pos > -1 && hline_begin_tag_pos > -1) {
  1564.     Ltable->layout[number_of_elements].begin_tag_pos = begin_tag_pos;
  1565.     Ltable->layout[number_of_elements].end_tag_pos = end_tag_pos;
  1566.     Ltable->layout[number_of_elements].hline_begin_tag_pos = hline_begin_tag_pos;
  1567.     Ltable->layout[number_of_elements].len = n_len;
  1568.     Ltable->layout[number_of_elements].offset = (n_offset == 0)?0:n_offset+1;
  1569.     Ltable->number_of_headlines += 1;
  1570.     ++Nheadline;
  1571.   }
  1572.   else {
  1573.     if(end_tag_pos > -1) {
  1574.       Ltable->layout[number_of_elements].end_tag_pos = end_tag_pos;
  1575.       Ltable->number_of_headlines += 1;
  1576.       ++Nheadline;
  1577.     }
  1578.     else {
  1579.       if(hline_begin_tag_pos > -1) {
  1580.     Ltable->layout[number_of_elements].hline_begin_tag_pos = hline_begin_tag_pos;
  1581.       }
  1582.       else Ltable->layout[number_of_elements].hline_begin_tag_pos = -1;
  1583.       Ltable->layout[number_of_elements].begin_tag_pos = begin_tag_pos;
  1584.       Ltable->layout[number_of_elements].len = n_len;
  1585.       Ltable->layout[number_of_elements].offset = (n_offset == 0)?0:n_offset+1;
  1586.     }
  1587.   }
  1588.   return;                    /* return(0); (up) */
  1589. }
  1590. /* ------------------------------------------------------------- */
  1591.  
  1592. static void put_record_end_Ltable(regexp_pos)
  1593.      long regexp_pos;
  1594. {
  1595.   if(Ltable == NULL)
  1596.     Ltable = (ltable*)s_malloc((size_t)sizeof(ltable));
  1597.   
  1598.   Ltable->date_tag_pos = -1;
  1599.   Ltable->date_begin_tag_pos = -1;
  1600.   Ltable->field_record_end_pos = regexp_pos;
  1601.   return;                    /* return(0); (up) */
  1602. }
  1603.  
  1604. /* ------------------------------------------------------------- */
  1605.  
  1606. static void put_hdate_ltable(begin_tag_pos, sscanf_arg, date1, date2, date3, date_begin_tag_pos)
  1607.      long begin_tag_pos;
  1608.      char* sscanf_arg;
  1609.      char* date1;
  1610.      char* date2;
  1611.      char* date3;
  1612.      long date_begin_tag_pos;
  1613. {
  1614.   long s_len;
  1615.   
  1616.   if(Ltable != NULL) {
  1617.     if(Ltable->sscanf_arg != NULL)
  1618.       s_free(Ltable->sscanf_arg);
  1619.     if(date_begin_tag_pos > -1) 
  1620.       Ltable->date_begin_tag_pos = date_begin_tag_pos;
  1621.     else Ltable->date_begin_tag_pos = -1;
  1622.     Ltable->date_tag_pos = begin_tag_pos;
  1623.     Ltable->date_desc = (char*)s_malloc((size_t)(sizeof(char) * 4));
  1624.     Ltable->date_desc[0] = date1[0];
  1625.     Ltable->date_desc[1] = date2[0];
  1626.     Ltable->date_desc[2] = date3[0];
  1627.     s_len = strlen(sscanf_arg);
  1628.     Ltable->sscanf_arg = (char*)s_malloc((size_t)(sizeof(char) * s_len));
  1629.     s_strncpy(Ltable->sscanf_arg, sscanf_arg, s_len);
  1630.   }
  1631. }
  1632.     
  1633. /* ------------------------------------------------------------- */
  1634.  
  1635. static long insert_regexp(regexp, number_of_elements, regexp_pos)
  1636.      char* regexp;
  1637.      long number_of_elements;
  1638.      long* regexp_pos;
  1639. {
  1640.   long i;
  1641.   long len1 = strlen(regexp);
  1642.   long len2;
  1643.   
  1644.   if(regexp_set == NULL) {
  1645.     Maxregexp = number_of_elements + MAX_REGEXP;
  1646.     regexp_set = (char**)s_malloc((size_t)(sizeof(char*) * Maxregexp));
  1647.   }
  1648.   else {
  1649.     if(number_of_elements == Maxregexp) {
  1650.       Maxregexp =  number_of_elements+ 10;
  1651.       regexp_set = (char**)s_realloc(regexp_set, 
  1652.                                      (size_t)(sizeof(char*) * Maxregexp));
  1653.     }
  1654.   }
  1655.   for(i=0; i<number_of_elements; i++) {
  1656.     len2 = strlen(regexp_set[i]);
  1657.     if((len1 - 1) == len2)
  1658.       if(strncmp(regexp, regexp_set[i], len2) == 0) {
  1659.         *regexp_pos = i;
  1660.         return(0);
  1661.       }
  1662.   }
  1663.   *regexp_pos = number_of_elements;
  1664.   regexp_set[number_of_elements] = (char*)s_malloc((size_t)(sizeof(char) * len1));
  1665.   s_strncpy(regexp_set[number_of_elements], regexp, len1);
  1666.   return(1);
  1667. }
  1668.                           
  1669.  
  1670. /* ------------------------------------------------------------- */
  1671. static long create_index_fields(stream)
  1672.      FILE* stream;
  1673. {
  1674.   yydebug =1;
  1675.   yyin = stream;
  1676.   number_of_index_fields = 0;
  1677.   if (!yyparse()) {
  1678.     waislog(WLOG_LOW, WLOG_INFO, "Syntax ok\n");
  1679.   }
  1680.   else return(-1);
  1681.   number_of_indextypes = 0;
  1682.   return(number_of_index_fields);
  1683. }
  1684.  
  1685.  
  1686. /* insert all field specification.
  1687.    return -1 if error.
  1688. */
  1689.  
  1690. #define format_ext ".fmt"
  1691.  
  1692. long init_add_fields(name, global_dictionary_exists, db)
  1693.      char* name;
  1694.      boolean* global_dictionary_exists;
  1695.      database* db;
  1696. {
  1697.   FILE* input_stream = NULL;
  1698.   char file[256];
  1699.   long number_of_fields = 0;
  1700.  
  1701.   s_strncpy(file, name, 255);
  1702.   s_strncat(file, format_ext, 255, 255);
  1703.   
  1704.   if(probe_file(file)) {
  1705.     input_stream = s_fopen(file, "r");
  1706.   }
  1707.   if(NULL == input_stream) {
  1708.     waislog(WLOG_HIGH, WLOG_ERROR, 
  1709.         "File_description %s does not exist", file);
  1710.     return(-1);
  1711.   }
  1712.  
  1713.   if(-1 == (number_of_fields = create_index_fields(input_stream)))
  1714.     return(-1);
  1715.   if(-1 == compile_regexp(number_of_regexp, regexp_set)) {
  1716.     fprintf(stderr, "compile regexp fails\n");
  1717.     clear_regexp(number_of_regexp);
  1718.     return(-1);
  1719.   }
  1720.   clear_regexp(number_of_regexp);
  1721.   s_fclose(input_stream);
  1722.   *global_dictionary_exists = global_dct_exists;
  1723.   db->number_of_fields = number_of_fields;
  1724.   db->index_fields = index_fields;
  1725.   return(number_of_fields);
  1726. }
  1727.  
  1728.  
  1729. /* ------------------------------------------------------------- */
  1730.